#ifndef MW_WEBENGINEVIEW_H
#define MW_WEBENGINEVIEW_H

#include <QMainWindow>
#include <QtWebEngineWidgets>
#include "../txtOper_qt5142_vs17/TxtOper.h"
#include "TB_searchTitleGoodrate.h"

namespace Ui {
class MW_WebEngineView;
}

enum ETimeStrType
{
    tstDateTimeMillisecond,
    tstTimeMillisecond,
};

extern QString g_strHashKey;

class MW_WebEngineView : public QMainWindow
{
    Q_OBJECT

public:
    explicit MW_WebEngineView(QWidget *parent = nullptr);
    ~MW_WebEngineView();

private slots:
    void on_pbtnOpenURL_clicked();

    void on_pbtnShowHideWEV_clicked();

    void on_pbtnXlhCookie_clicked();

    void on_pbtnFxlhCookie_clicked();

    void on_pbtnRefresh_clicked();

    void on_pbtnClearMsg_clicked();

public:
    // 若是load(...)或是setUrl(...)打开的网页会有 事件loadFinished(...)触发。
    // 但是若是像登陆成功，它只会本页跳转 只有loadProgress(...)事件 没有loadFinished(...)事件触发。
    // ∴ 需要区分
    //bool FbSetUrl;

private:
    Ui::MW_WebEngineView *ui;

    bool FbShow_WebEngineView;
    QWebEngineView FweView;
    JS_Oper FjsOper;

    QDateTime FdtUrlSet, FdtUrlLoadStart, FdtUrlLoadFinished;
    QHash<QString, QString> FhashCookie;
    //QTimer timerJS;// = new QTimer(this);

    QDateTime FdtPercent100;// WEP_LoadProgress网页加载达到100%时使用的

    QString FstrIniFile;// ini配置文件的完整路径+文件名

    TB_searchTitleGoodrate searchShop;

public:
    void SetURL(QString _strURL);
    void SetINI(QString _strINI);

public:
    void AddMsg(QString _str);
    QString TimeStr(ETimeStrType tst, QDateTime *_pTime);
    void Timer_Timeout();

    static void Ini_JieMi(QString _strIniFile, QString _strNodeName, QString _strKeyName, QString *_pstrOut);

private:
    void WEP_LoadStarted();
    void WEP_LoadProgress(int progress);
    void WEP_LoadFinished(bool _ok);

    void WEP_ScrollPositionChanged(const QPointF &position);
    void WEP_UrlChanged(const QUrl &url);

    void CookieAdded(const QNetworkCookie &cookie);

private:

};

#endif // MW_WEBENGINEVIEW_H
